#include <stdio.h>

typedef int t;
typedef t q[3];

int globalvar = 400;

// Decl
void test(int p1, float p2);

/*
 * Def
 */
void test(int p1, float p2) {
	int a;
	float b = 3.5;
	int f = b - 1;
	a = b;
	char c[4] = {'a','b'};
	c[2] = 'c';
	//t x = {1,2};

    int array[b][b] = {1,2,3};
    array[f][1] = 5;

	int nest() {
		return 6;
	}

	float d = nest();

	if (d > 0) {
		while (d > 0) {
			d = d-1;
			if (d == 2) {
				break;
			} else {
				continue;
			}
		}
	}

	//char test[3] = "tes";

	const char ch = 'e';

	printf("test %i test %3f", a, d);
	//scanf("%i %4f", a, d);
}

int test2(int array[4]) {
	return array[2];
}

int faculteit(int i){
	if (i > 0){
		int prev = faculteit(i-1);
		printf("%i \n", prev);
		return prev*i;
	}else {
		return 1;
	}
}

void main() {
	// General
	test(1, 3.3);
	printf("%f\n",4.4*(int)4.4);

	// Array parameters
	int array[4] = {1,2,3};
	int result = test2(array);
	printf("result %i \n", result);

	// Recursion with scanf
	int number;
	scanf("getal? %i", number);
	int result2 = faculteit(number);
	printf("result %i \n", result2);

	// Cast
	float res3f = 3.89;
	int result3 = (int)res3f;
	printf("result %f becomes %i \n",res3f, result3);

	// Nested function
	int test3(int q) {
		return q*q;
	}
	int result4 = test3(8);
	printf("result %i \n", result4);

	// Print string
	char string2[10] = {'a', 'b', 'c'};
	printf("%s\n", string2);

	// Optimalization of term
	float result5 = 7.5*(8.3-6.4)+(6.2/5.34);
	printf("result %f \n", result5);

	// Optimalization of if/while
	if (1==1) {
		printf("compiled \n");
	} else {
		printf("not compiled \n");
	}

	// Conversion of return type
	int test4(float s) {
		return s;
	}
	int result6 = test4(5.234);
	printf("result %i \n", result6);

	// Multidimensional array
	int array2[2][2][2] = {1,2,3,4,5,6};
	printf("result %i \n", array2[1][0][0]);

	// Global variable
	printf("result %i \n", globalvar);
}
